package com.kgc.kmall.kmallitemweb.controller;

import com.kgc.kmall.bean.PmsProductSaleAttr;
import com.kgc.kmall.bean.PmsSkuInfo;
import com.kgc.kmall.service.SkuService;
import com.kgc.kmall.service.SpuService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class ItemController {
    @Reference
    SkuService skuService;
    @Reference
    SpuService spuService;
    @RequestMapping("{skuId}.html")
    public String item(@PathVariable Long skuId, Model model){
        PmsSkuInfo pmsSkuInfo=skuService.selectBySkuId(skuId);
        model.addAttribute("skuInfo",pmsSkuInfo);
        List<PmsProductSaleAttr> saleAttrList = spuService.spuSaleAttrListIsCheckService(pmsSkuInfo.getSpuId(), pmsSkuInfo.getId());
        //显示销售属性
        model.addAttribute("spuSaleAttrListCheckBySku",saleAttrList);

        return "item";
    }

}
